package com.example.demo.config.cos;

import com.qiniu.common.Zone;
import com.qiniu.storage.UploadManager;
import com.qiniu.util.Auth;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author :xie
 * Email: 1487471733@qq.com
 * Date: 2018/2/9
 * Time: 21:14
 * Describe:
 */
@Configuration
public class UploadManagers {

    @Autowired
    private Auth auth;
    @Autowired
    private CosConfigProperties cosConfigProperties;


    @Bean
    public UploadManager uploadManager(){
        String upToken= auth.uploadToken(cosConfigProperties.getBucketName());

        com.qiniu.storage.Configuration cfg = new com.qiniu.storage.Configuration(Zone.zone2());
        com.qiniu.storage.UploadManager uploadManager = new com.qiniu.storage.UploadManager(cfg);

            return uploadManager;
    }
}
